import request from '@/utils/request.js'

/**
 *获取文章列表
 * @param {object} params {channel_id,timestam,with_top}
 * @returns promise
 */
export const getArticleList = params => {
  return request({
    method: 'GET',
    url: '/v1_1/articles',
    params
  })
}

// 获取文章详情
export const getArticleInfo = id => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${id}`
  })
}
// 收藏文章
export const addCollected = id => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target: id
    }
  })
}

// 取消收藏文章
export const deleteCollected = target => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${target}`
  })
}

// 对文章不喜欢
export const setDislike = id => {
  return request({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    data: {
      target: id
    }
  })
}

// 对文章喜欢
export const setLike = id => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target: id
    }
  })
}
